home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / include / malloc.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-05-08  |  7.5 KB  |  241 lines

  1. /* Prototypes and definition for malloc implementation.
  2.    Copyright (C) 1996,97,99,2000,2002,2003,2004 Free Software Foundation, Inc.
  3.    This file is part of the GNU C Library.
  4.  
  5.    The GNU C Library is free software; you can redistribute it and/or
  6.    modify it under the terms of the GNU Lesser General Public
  7.    License as published by the Free Software Foundation; either
  8.    version 2.1 of the License, or (at your option) any later version.
  9.  
  10.    The GNU C Library is distributed in the hope that it will be useful,
  11.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.    Lesser General Public License for more details.
  14.  
  15.    You should have received a copy of the GNU Lesser General Public
  16.    License along with the GNU C Library; if not, write to the Free
  17.    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  18.    02111-1307 USA.  */
  19.  
  20. #ifndef _MALLOC_H
  21. #define _MALLOC_H 1
  22.  
  23. #include <features.h>
  24.  
  25. /*
  26.   $Id: malloc.h,v 1.26.4.1 2005/02/16 10:16:11 roland Exp $
  27.   `ptmalloc2', a malloc implementation for multiple threads without
  28.   lock contention, by Wolfram Gloger <wg@malloc.de>.
  29.  
  30.   VERSION 2.7.0
  31.  
  32.   This work is mainly derived from malloc-2.7.0 by Doug Lea
  33.   <dl@cs.oswego.edu>, which is available from:
  34.  
  35.                  ftp://gee.cs.oswego.edu/pub/misc/malloc.c
  36.  
  37.   This trimmed-down header file only provides function prototypes and
  38.   the exported data structures.  For more detailed function
  39.   descriptions and compile-time options, see the source file
  40.   `malloc.c'.
  41. */
  42.  
  43. #if defined(__STDC__) || defined (__cplusplus)
  44. # include <stddef.h>
  45. # define __malloc_ptr_t  void *
  46. #else
  47. # undef  size_t
  48. # define size_t          unsigned int
  49. # undef  ptrdiff_t
  50. # define ptrdiff_t       int
  51. # define __malloc_ptr_t  char *
  52. #endif
  53.  
  54. #ifdef _LIBC
  55. /* Used by GNU libc internals. */
  56. # define __malloc_size_t size_t
  57. # define __malloc_ptrdiff_t ptrdiff_t
  58. #elif !defined __attribute_malloc__
  59. # define __attribute_malloc__
  60. #endif
  61.  
  62. #ifdef __GNUC__
  63.  
  64. /* GCC can always grok prototypes.  For C++ programs we add throw()
  65.    to help it optimize the function calls.  But this works only with
  66.    gcc 2.8.x and egcs.  */
  67. # ifndef __THROW
  68. #  if defined __cplusplus && (__GNUC__ >= 3 || __GNUC_MINOR__ >= 8)
  69. #   define __THROW    throw ()
  70. #  else
  71. #   define __THROW
  72. #  endif
  73. # endif
  74. # define __MALLOC_P(args)    args __THROW
  75. /* This macro will be used for functions which might take C++ callback
  76.    functions.  */
  77. # define __MALLOC_PMT(args)    args
  78.  
  79. #else    /* Not GCC.  */
  80.  
  81. # define __THROW
  82.  
  83. # if (defined __STDC__ && __STDC__) || defined __cplusplus
  84.  
  85. #  define __MALLOC_P(args)    args
  86. #  define __MALLOC_PMT(args)    args
  87.  
  88. #  ifndef __const
  89. #   define __const     const
  90. #  endif
  91.  
  92. # else    /* Not ANSI C or C++.  */
  93.  
  94. #  define __MALLOC_P(args)    ()    /* No prototypes.  */
  95. #  define __MALLOC_PMT(args)    ()
  96.  
  97. #  ifndef __const
  98. #   define __const
  99. #  endif
  100.  
  101. # endif    /* ANSI C or C++.  */
  102.  
  103. #endif    /* GCC.  */
  104.  
  105. #ifndef NULL
  106. # ifdef __cplusplus
  107. #  define NULL    0
  108. # else
  109. #  define NULL    ((__malloc_ptr_t) 0)
  110. # endif
  111. #endif
  112.  
  113. #ifdef __cplusplus
  114. extern "C" {
  115. #endif
  116.  
  117. /* Allocate SIZE bytes of memory.  */
  118. extern __malloc_ptr_t malloc __MALLOC_P ((size_t __size)) __attribute_malloc__;
  119.  
  120. /* Allocate NMEMB elements of SIZE bytes each, all initialized to 0.  */
  121. extern __malloc_ptr_t calloc __MALLOC_P ((size_t __nmemb, size_t __size))
  122.        __attribute_malloc__;
  123.  
  124. /* Re-allocate the previously allocated block in __ptr, making the new
  125.    block SIZE bytes long.  */
  126. extern __malloc_ptr_t realloc __MALLOC_P ((__malloc_ptr_t __ptr,
  127.                        size_t __size))
  128.        __attribute_malloc__;
  129.  
  130. /* Free a block allocated by `malloc', `realloc' or `calloc'.  */
  131. extern void free __MALLOC_P ((__malloc_ptr_t __ptr));
  132.  
  133. /* Free a block allocated by `calloc'. */
  134. extern void cfree __MALLOC_P ((__malloc_ptr_t __ptr));
  135.  
  136. /* Allocate SIZE bytes allocated to ALIGNMENT bytes.  */
  137. extern __malloc_ptr_t memalign __MALLOC_P ((size_t __alignment, size_t __size));
  138.  
  139. /* Allocate SIZE bytes on a page boundary.  */
  140. extern __malloc_ptr_t valloc __MALLOC_P ((size_t __size)) __attribute_malloc__;
  141.  
  142. /* Equivalent to valloc(minimum-page-that-holds(n)), that is, round up
  143.    __size to nearest pagesize. */
  144. extern __malloc_ptr_t  pvalloc __MALLOC_P ((size_t __size))
  145.        __attribute_malloc__;
  146.  
  147. /* Underlying allocation function; successive calls should return
  148.    contiguous pieces of memory.  */
  149. extern __malloc_ptr_t (*__morecore) __MALLOC_PMT ((ptrdiff_t __size));
  150.  
  151. /* Default value of `__morecore'.  */
  152. extern __malloc_ptr_t __default_morecore __MALLOC_P ((ptrdiff_t __size))
  153.        __attribute_malloc__;
  154.  
  155. /* SVID2/XPG mallinfo structure */
  156.  
  157. struct mallinfo {
  158.   int arena;    /* non-mmapped space allocated from system */
  159.   int ordblks;  /* number of free chunks */
  160.   int smblks;   /* number of fastbin blocks */
  161.   int hblks;    /* number of mmapped regions */
  162.   int hblkhd;   /* space in mmapped regions */
  163.   int usmblks;  /* maximum total allocated space */
  164.   int fsmblks;  /* space available in freed fastbin blocks */
  165.   int uordblks; /* total allocated space */
  166.   int fordblks; /* total free space */
  167.   int keepcost; /* top-most, releasable (via malloc_trim) space */
  168. };
  169.  
  170. /* Returns a copy of the updated current mallinfo. */
  171. extern struct mallinfo mallinfo __MALLOC_P ((void));
  172.  
  173. /* SVID2/XPG mallopt options */
  174. #ifndef M_MXFAST
  175. # define M_MXFAST  1    /* maximum request size for "fastbins" */
  176. #endif
  177. #ifndef M_NLBLKS
  178. # define M_NLBLKS  2    /* UNUSED in this malloc */
  179. #endif
  180. #ifndef M_GRAIN
  181. # define M_GRAIN   3    /* UNUSED in this malloc */
  182. #endif
  183. #ifndef M_KEEP
  184. # define M_KEEP    4    /* UNUSED in this malloc */
  185. #endif
  186.  
  187. /* mallopt options that actually do something */
  188. #define M_TRIM_THRESHOLD    -1
  189. #define M_TOP_PAD           -2
  190. #define M_MMAP_THRESHOLD    -3
  191. #define M_MMAP_MAX          -4
  192. #define M_CHECK_ACTION      -5
  193.  
  194. /* General SVID/XPG interface to tunable parameters. */
  195. extern int mallopt __MALLOC_P ((int __param, int __val));
  196.  
  197. /* Release all but __pad bytes of freed top-most memory back to the
  198.    system. Return 1 if successful, else 0. */
  199. extern int malloc_trim __MALLOC_P ((size_t __pad));
  200.  
  201. /* Report the number of usable allocated bytes associated with allocated
  202.    chunk __ptr. */
  203. extern size_t malloc_usable_size __MALLOC_P ((__malloc_ptr_t __ptr));
  204.  
  205. /* Prints brief summary statistics on stderr. */
  206. extern void malloc_stats __MALLOC_P ((void));
  207.  
  208. /* Record the state of all malloc variables in an opaque data structure. */
  209. extern __malloc_ptr_t malloc_get_state __MALLOC_P ((void));
  210.  
  211. /* Restore the state of all malloc variables from data obtained with
  212.    malloc_get_state(). */
  213. extern int malloc_set_state __MALLOC_P ((__malloc_ptr_t __ptr));
  214.  
  215. /* Called once when malloc is initialized; redefining this variable in
  216.    the application provides the preferred way to set up the hook
  217.    pointers. */
  218. extern void (*__malloc_initialize_hook) __MALLOC_PMT ((void));
  219. /* Hooks for debugging and user-defined versions. */
  220. extern void (*__free_hook) __MALLOC_PMT ((__malloc_ptr_t __ptr,
  221.                     __const __malloc_ptr_t));
  222. extern __malloc_ptr_t (*__malloc_hook) __MALLOC_PMT ((size_t __size,
  223.                             __const __malloc_ptr_t));
  224. extern __malloc_ptr_t (*__realloc_hook) __MALLOC_PMT ((__malloc_ptr_t __ptr,
  225.                              size_t __size,
  226.                              __const __malloc_ptr_t));
  227. extern __malloc_ptr_t (*__memalign_hook) __MALLOC_PMT ((size_t __alignment,
  228.                               size_t __size,
  229.                               __const __malloc_ptr_t));
  230. extern void (*__after_morecore_hook) __MALLOC_PMT ((void));
  231.  
  232. /* Activate a standard set of debugging hooks. */
  233. extern void __malloc_check_init __MALLOC_P ((void));
  234.  
  235.  
  236. #ifdef __cplusplus
  237. } /* end of extern "C" */
  238. #endif
  239.  
  240. #endif /* malloc.h */
  241.